#pragma once

#include <context.hpp>
#include "serial.hpp"

#if OS==OS_WINDOWS

#include <Windows.h>
#include <process.h>
#include <iostream>

class WinSerial : public Serial
{
public:
	WinSerial(
		const char* port = "",
		uint32_t baudrate = DEFAULT_BAUD_RATE,
		uint8_t databits = DEFAULT_DATA_BITS,
		uint8_t parity = DEFAULT_PARITY,
		uint8_t stopbits = DEFAULT_STOP_BITS,
		uint8_t flowCtrl = DEFAULT_FLOW_CTRL
		);
	~WinSerial();
	virtual bool config();
	virtual bool open();
	virtual bool close();
	virtual uint32_t tx(uint8_t* data, uint32_t len);
	virtual uint32_t rx(uint8_t* data, uint32_t len);
protected:
	DCB     dcb;
	COMMTIMEOUTS  commTimeouts;
	HANDLE  handle;
};

#endif

